package com.xq.springboot.service.impl;

import com.xq.springboot.mapper.PeopleMapper;
import com.xq.springboot.pojo.People;
import com.xq.springboot.service.PeopleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author xq
 * @version 1.0
 * @date 2021/4/18 17:41
 * @description 人们业务服务接口实现层
 */
@Service
//@Transactional // 所有方法全部加上事务
//@Transactional(propagation = Propagation.REQUIRED) // 默认是开启事务的
public class PeopleServiceImpl  implements PeopleService {
    @Autowired
    private PeopleMapper peopleMapper;

    @Override
    @Transactional
    public int addPeople(People people) {
        return this.peopleMapper.addPeople(people);
    }

    @Override
    @Transactional
    public int deleteById(Integer id) {
        return this.peopleMapper.deleteById(id);
    }

    @Override
    @Transactional
    public int updatePeopleById(People people) {
        return this.peopleMapper.updatePeopleById(people);
    }

    @Override
    public List<People> getPeopleAll() {
        return this.peopleMapper.getPeopleAll();
    }
}
